<!DOCTYPE html>
<html lang="en">

<include file="CommonSidebar:common-head"/>
<link rel="stylesheet" href="__ROOT__/Application/Admin/Public/css/common.css">
<link href="__ROOT__/Application/Admin/Public/css/jquery.datetimepicker.css" rel="stylesheet">
<body>

<div id="wrapper">

    <!-- Navigation -->
    <include file="CommonSidebar:common-navbar"/>

    <div id="page-wrapper">
        <div class="row">
            <div class="col-lg-12">
                <h1 class="page-header">所有书籍</h1>
            </div>
        </div>
        <div class="row">
            <div class="col-md-12">
                <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
                    <div class="panel panel-default">
                        <div class="panel-heading" role="tab" id="headingOne">
                            <h4 class="panel-title">
                                <a role="button" data-toggle="collapse" data-parent="#accordion"
                                   href="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
                                    搜索栏
                                </a>
                            </h4>
                        </div>
                        <div id="collapseOne" class="panel-collapse collapse in" role="tabpanel"
                             aria-labelledby="headingOne">
                            <div class="panel-body">
                                <form action="{:U('Index')}" class="form-horizontal" method="get">

                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">一级分类</label>

                                        <div class="col-sm-4">
                                            <select class="form-control" name="region_one" value="{$CSDATA.region_one}">
                                                <option value="">ALL</option>
                                                <foreach name="type_one" item="v" key="k">
                                                    <option value="{$v.region_one}">{$v.region_one}</option>
                                                </foreach>
                                            </select>
                                        </div>
                                        <label class="col-sm-2 control-label">二级分类</label>

                                        <div class="col-sm-4">
                                            <select class="form-control" name="region_two">
                                                <option value="">ALL</option>
                                                <foreach name="type_two" item="v" key="k">
                                                    <option value="{$v.region_two}">{$v.region_two}</option>
                                                </foreach>
                                            </select>
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">书籍名称</label>

                                        <div class="col-sm-4">
                                            <input class="form-control" name="TITLE" value="{$CSDATA.TITLE}">
                                        </div>
                                        <label class="col-sm-2 control-label">条形码</label>

                                        <div class="col-sm-4">
                                            <input class="form-control" name="ISBN" value="{$CSDATA.ISBN}">
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">作者名称</label>

                                        <div class="col-sm-4">
                                            <input class="form-control" name="AUTHOR" value="{$CSDATA.AUTHOR}">
                                        </div>
                                        <label class="col-sm-2 control-label">出版社</label>

                                        <div class="col-sm-4">
                                            <input class="form-control" name="PRESS" value="{$CSDATA.PRESS}">
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">是否入库</label>

                                        <div class="col-sm-4">
                                            <select class="form-control" name="STATE">
                                                <option value="">ALL</option>
                                                <option value="入库">入库</option>
                                                <option value="未入库">未入库</option>
                                            </select>
                                        </div>
                                        <label class="col-sm-2 control-label">是否上架</label>

                                        <div class="col-sm-4">
                                            <select class="form-control" name="SXJ">
                                                <option value="">ALL</option>
                                                <option value="1">上架</option>
                                                <option value="-1">下架</option>
                                            </select>
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">书籍包装</label>

                                        <div class="col-sm-4">
                                            <select class="form-control" name="PACKING_SPECIFICATION">
                                                <option value="">ALL</option>
                                                <foreach name="BOOK_BZ" item="v" key="k">
                                                    <option value="{$v.region_name}">{$v.region_name}</option>
                                                </foreach>
                                            </select>
                                        </div>
                                        <label class="col-sm-2 control-label">适读年龄段</label>

                                        <div class="col-sm-4">
                                            <select class="form-control" name="AGE">
                                                <option value="">ALL</option>
                                                <foreach name="BOOK_AGE" item="v" key="k">
                                                    <option value="{$v.region_name}">{$v.region_name}</option>
                                                </foreach>
                                            </select>
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">可能有误书籍颜色</label>

                                        <div class="col-sm-4">
                                            <select class="form-control" name="RED">
                                                <option value="">ALL</option>
                                                <option style="color: red" value="1">书名重复</option>
                                                <option style="color: blue" value="2">ISBN重复</option>
                                                <option style="color: indigo" value="3">ISBN为空</option>
                                            </select>
                                        </div>
                                        <label class="col-sm-2 control-label">是否黑名单</label>

                                        <div class="col-sm-4">
                                            <select class="form-control" name="IS_BLACK">
                                                <option value="">ALL</option>
                                                <option value="0">白名单</option>
                                                <option value="1">黑名单</option>
                                            </select>
                                        </div>
                                    </div>

                                    <input class="form-control" type="hidden" name="SGCODE" value="{$SGCODE}">
                                    <input class="form-control" type="hidden" name="SS" value="{$SS}">
                                    <input class="form-control" type="hidden" name="banner_id" value="{$banner_id}">
                                    <input class="form-control" type="hidden" name="TZ" value="{$TZ}">
                                    <input class="form-control" type="hidden" name="BY" value="{$BY}">

                                    <div class="form-group">
                                        <div class="col-sm-10 col-sm-offset-2">
                                            <button type="submit" class="btn  btn-primary">筛选</button>
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <div class="row">
            <div class="col-lg-12">
                <!--<div class="row">-->
                <!--<div class="col-md-12">-->
                <!--<button onclick='checkboxID()' class="btn  btn-primary">导入书篮子</button>-->
                <!--</div>-->
                <!--</div>-->
                <div class="row">
                    <div class="col-lg-1">
                        <button onclick='listshow(1,$(this))' class="btn  btn-primary">作者</button>
                    </div>
                    <div class="col-lg-1">
                        <button onclick='listshow(2,$(this))' class="btn  btn-primary">出版社</button>
                    </div>
                    <div class="col-lg-1">
                        <button onclick='listshow(3,$(this))' class="btn  btn-primary">上下架情况</button>
                    </div>
                    <div class="col-lg-1">
                        <button onclick='listshow(4,$(this))' class="btn  btn-primary">排序</button>
                    </div>
                    <div class="col-lg-1">
                        <button onclick='listshow(5,$(this))' class="btn  btn-primary">书籍包装</button>
                    </div>
                    <div class="col-lg-1">
                        <button onclick='listshow(6,$(this))' class="btn  btn-primary">入库情况</button>
                    </div>
                    <div class="col-lg-1">
                        <button onclick='listshow(7,$(this))' class="btn  btn-primary">年龄</button>
                    </div>
                    <div class="col-lg-1">
                        <button onclick='listshow(8,$(this))' class="btn  btn-primary">图片</button>
                    </div>
                    <div class="col-lg-1">
                        <button onclick='listshow(9,$(this))' class="btn  btn-primary">库存</button>
                    </div>
                    <div class="col-lg-1">
                        <button onclick='listshow(10,$(this))' class="btn  btn-primary">书籍定价</button>
                    </div>
                    <div class="col-lg-1">
                        <button onclick='listshow(11,$(this))' class="btn  btn-primary">书籍最低销售价</button>
                    </div>
                </div>
                <div class="row">
                    <div class="col-md-12 dataTable_wrapper">
                        <table id="my-orders" class="table table-responsive table-bordered" style="margin-top: 10px"
                               border="0">
                            <tr style="color: #008200;color-interpolation: red;align-content: center">
                                <th width="8px" style="text-align:center"><input name="all_checkbox" type='checkbox'
                                                                                 id="all_checkbox"></th>
                                <th style="text-align:center" width="25px">平台编码</th>
                                <th style="text-align:center" width="140px">条形码</th>
                                <th style="text-align:center" width="250px">书名</th>
                                <th style="text-align:center" id="list1" hidden>作者</th>
                                <th style="text-align:center" id="list2" hidden>出版社</th>
                                <th style="text-align:center" id="list3" hidden>上下架情况</th>
                                <!--<th style="text-align:center">库存</th>-->
                                <th width="100px" style="text-align:center" data-type="{$CSDATA.isDESC}" name="SORT"
                                    onclick="sort($(this))" id="list4" hidden>排序
                                </th>
                                <th style="text-align:center" id="list5" hidden>书籍包装</th>
                                <th style="text-align:center" id="list6" hidden>入库情况</th>
                                <th style="text-align:center" id="list7" hidden>年龄</th>
                                <th style="text-align:center" id="list8" hidden>图片</th>
                                <th style="text-align:center" id="list9" hidden>库存</th>
                                <th style="text-align:center" id="list10" data-type="{$CSDATA.isDESC}" name="Y_PRICE"
                                    onclick="sort($(this))" hidden>书籍定价
                                </th>
                                <th style="text-align:center" id="list11" data-type="{$CSDATA.isDESC}" name="XS_PRICE"
                                    onclick="sort($(this))" hidden>书籍最低销售价
                                </th>
                                <th style="text-align:center" width="10%">操作</th>
                            </tr>
                            <tfoot>
                            <tr>
                                <td colspan="13">
                                    <div class="pagination">
                                        {$page}
                                    </div>
                                    <div class="clear">{$search}</div>
                                </td>
                            </tr>
                            </tfoot>
                            <tbody id="context">
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>

    </div>
</div>

<!--副本-->
<div id="allayModal" class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog"
     aria-labelledby="mySmallModalLabel">
    <div class="modal-dialog modal-sm">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                        aria-hidden="true">&times;</span></button>
                <h4 class="modal-title text-center">添加书籍其他成色副本</h4>
            </div>
            <form id="profitForm" action="{:U('Add_fb')}" method="post" enctype="multipart/form-data">
                <div class="modal-body">
                    <div class="container-fluid">
                        <div class="row">
                            <input id="BOOK_ID" type="hidden" name="BOOK_ID" value="">

                            <div class="col-xs-12">
                                <label>书籍副本名称</label>
                                <input id="book_name_fb" name="book_name_fb" class="rugby-login form-control" value="">
                            </div>
                            <div class="col-xs-12">
                                <label>书籍副本销售价格</label>
                                <input id="XS_PRICE" name="XS_PRICE" class="rugby-login form-control" value="">
                            </div>
                            <div class="col-xs-12">
                                <label>书籍副本成色</label>
                                <select type="text" class="form-control" name="book_name_LEVEL">
                                    <foreach name="BOOK_LEVEL" item="v" key="k">
                                        <option value="{$v.region_name}">{$v.region_name}</option>
                                    </foreach>
                                </select>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="submit">
                        确认
                    </button>
                </div>
            </form>
        </div>

    </div>
</div>
<!--副本-->

<!--成色-->
<div id="allayModal_1" class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog"
     aria-labelledby="mySmallModalLabel">
    <div class="modal-dialog modal-sm">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                        aria-hidden="true">&times;</span></button>
                <h4 class="modal-title text-center">书籍成色选择器</h4>
            </div>
            <!--<form action="{:U('Add')}" method="post" enctype="multipart/form-data">-->
            <div class="modal-body">
                <div class="container-fluid">
                    <div class="row">
                        <input id="L_BOOK_ID" type="hidden" name="BOOK_ID" value="">

                        <div class="col-xs-12">
                            <foreach name="BOOK_LEVEL_JSD" item="v" key="k">
                                <div class="row">
                                    <span style="text-align:left;font-size: large" class=" control-label">{$v.region_name}</span>
                                </div>
                                <foreach name="v.son" item="v1" key="k1">
                                    <div class="row">
                                        <input type="checkbox" name="jsd" value="{$v1.region_code}">
                                        <lable value="{$v1.region_name}">{$v1.region_name}</lable>
                                    </div>
                                </foreach>

                            </foreach>
                        </div>
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button onclick="Level_handling();">
                    确认
                </button>
            </div>
            <!--</form>-->
        </div>

    </div>
</div>
<!--成色-->

<!--确认成色-->
<div id="allayModal_2" class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog"
     aria-labelledby="mySmallModalLabel">
    <div class="modal-dialog modal-sm">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                        aria-hidden="true">&times;</span></button>
                <h4 class="modal-title text-center">确认成色</h4>
            </div>
            <!--<form action="{:U('Add')}" method="post" enctype="multipart/form-data">-->
            <div class="modal-body">
                <div class="container-fluid">
                    <div class="row">
                        <input id="LL_BOOK_ID" type="hidden" name="BOOK_ID" value="">

                        <div class="col-xs-12">
                            <label id="cs_data" name="cs"></label>
                            <!--<select name="cs">-->
                            <!--<option></option>-->
                            <!--</select>-->
                        </div>
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button onclick="qx();">
                    取消
                </button>
                <button onclick="qr();">
                    确认成色
                </button>
            </div>
            <!--</form>-->
        </div>

    </div>
</div>
<!--确认成色-->

<!--修改书籍排序号-->
<div id="changesort" class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog"
     aria-labelledby="mySmallModalLabel">
    <div class="modal-dialog modal-sm">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                        aria-hidden="true">&times;</span></button>
                <h4 class="modal-title text-center">修改书籍排序号</h4>
            </div>
            <div class="modal-body">
                <div class="container-fluid">
                    <div class="row">
                        <input id="order_id" type="hidden" name="order_id" value="">

                        <div class="col-xs-12">
                            <label>序号</label>
                            <input id="sortnum" name="sortnum" class="rugby-login form-control" value="">
                        </div>
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button onclick="updatecost()">
                    确认
                </button>
            </div>
        </div>
    </div>
</div>
<!--修改书籍排序号-->


<include file="CommonSidebar:common-script"/>
<script src="__ROOT__/Application/Admin/Public/js/jquery.datetimepicker.js"></script>
<!-- DataTables JavaScript -->
<script src="__ROOT__/Application/Admin/Public/bower_components/datatables/media/js/jquery.dataTables.min.js"></script>
<script src="__ROOT__/Application/Admin/Public/bower_components/datatables-plugins/integration/bootstrap/3/dataTables.bootstrap.min.js"></script>

<!-- Custom Theme JavaScript -->
<script src="__ROOT__/Application/Admin/Public/dist/js/sb-admin-2.js"></script>
<!-- Page-Level Demo Scripts - Tables - Use for reference -->


<script type="text/javascript" src="__ROOT__/Application/Admin/Public/LoadPading/LoadPading.js?v=3"></script>
<link rel="stylesheet" href="__ROOT__/Application/Admin/Public/LoadPading/LoadPading.css" type="text/css"
      media="screen"/>


<script>
    $(document).ready(function () {
        $('#dataTables-example').DataTable({
            responsive: true
        });
    });
    //修改价格
    var elem_all;
    function add(ID, elem) {
//        alert(elem.html());
        elem_all = elem;
        $("#order_id").val(ID);
        $("#sortnum").val(elem.html());
        $("#changesort").modal("show");
    }
    function updatecost() {
        var ID = $("#order_id").val();
        var sortnum = $("#sortnum").val();

        if (confirm("确认修改？")) {
            $.post("{:U('updatesort')}",
                    {ID: ID, sortnum: sortnum},
                    function (data) {
                        console.log(data);
                        if (parseInt(data) == 1) {
                            alert('修改成功');
                            elem_all.html(sortnum);
                        } else {
                            alert('修改失败');
                        }
                    });
            $("#changesort").modal("hide");
        }
    }

</script>
<script type="text/javascript">
    var showList = [];//显示列保存
    //显示列
    function listshow(num, elem) {
        if ($("#list" + num).is(":hidden")) {
            $("#list" + num).show();
            $(".list" + num).show();
            showList.push(num);
            elem.css('color', 'red');
        } else {
            $("#list" + num).hide();
            $(".list" + num).hide();
            showList.splice($.inArray(num, showList), 1);
            elem.css('color', '#777');
        }
    }

    <!--日期插件-->
    $('.datetimepicker_mask').datetimepicker({
        lang: 'ch',
        mask: '9999-19-39',
        format: 'Y-m-d',
        timepicker: false,    //关闭时间选项
        yearStart: 2000,     //设置最小年份
        yearEnd: 3050,        //设置最大年份
        todayButton: true,    //关闭选择今天按钮
        autoclose: true
    });
    var urlkey = getkey({$CSDATA_JOIN});
    console.log(urlkey);
    var url = "{:U('pageLoad_self')}" + urlkey;
    var LoadObj = new LoadPading(10, 5, url, 10, false);
    $(function () {
        LoadObj.initFun_Load();
        LoadPading.prototype.setDateScene = function (useSet) {
            console.log(useSet);
            $("#context").html("");
            for (var i in useSet) {
                switch (useSet[i]['RED']) {
                    case '1':
                        var html = '<tr style="color: red">';
                        break;
                    case '2':
                        var html = '<tr style="color: blue">';
                        break;
                    case '3':
                        var html = '<tr style="color: indigo">';
                        break;
                    default :
                        var html = '<tr>';
                        break;
                }
                if (useSet[i]['IS_BLACK'] == 1) {
                    var html = '<tr style="color: silver">';
                }
                if (useSet[i]['BOOK_ID']) {
                    html += "<td></td> ";
                } else {
                    html += "<td><input type='checkbox' name='checkbox' value='" + useSet[i]['ID'] + "' ></td> ";
                }
                html += "<td>" + useSet[i]['ID'] + "</td> " +
                        "<td>" + useSet[i]['ISBN'] + "</td> " +
                        "<td>" + useSet[i]['TITLE'] + "</td> " +
                        "<td class='list1' hidden>" + useSet[i]['AUTHOR'] + "</td> " +
                        "<td class='list2' hidden>" + useSet[i]['PRESS'] + "</td> ";
                if (useSet[i]['SXJ'] == 1) {
                    html += "<td class='list3' hidden> <span style='color: #008200'>上架中</span>";
                } else {
                    html += "<td class='list3' hidden><span style='color: red'>已下架</span> ";
                }
                html += " <button  data-id=" + useSet[i]['ID']
                        + " data-shelves='" + useSet[i]['SXJ']
                        + "' class='updateShelves'  onclick='updateShelves(" + useSet[i]['ID'] + ",$(this))'>" +
                        "修改" +
                        "</button>";
                html += "</td>";

                html += "<td class='list4' hidden>";
                html += "<button class='btn btn-link'  onclick=\"add('" + useSet[i]['ID'] + "',$(this))\" >" + useSet[i]['SORT'] + "</button>";
                html += "</td>";
                html += "<td class='list5' hidden>" + useSet[i]['PACKING_SPECIFICATION'] + "</td>";
                html += "</td> ";
                html += "<td class='list6' hidden> ";
                if (useSet[i]['STATE'] == '入库') {
                    html += "<span style='color: #0000cc'>入库</span>";
                } else {
                    html += "<span style='color: red'>未入库</span>";
                }
                html += "</td> ";
                html += "<td class='list7' hidden> " + useSet[i]['AGE'];
                html += "</td> ";
                html += "<td class='list8' hidden><img width='80px' src='" + useSet[i]['PIC_URL'] + "'> </td> "
                html += "<td class='list9' hidden>" + useSet[i]['STOCK'] + "</td> ";
                html += "<td class='list10' hidden>" + useSet[i]['Y_PRICE'] + "</td> ";
                html += "<td class='list11' hidden>" + useSet[i]['XS_PRICE'] + "</td> ";
                html += "<td> ";
                if (useSet[i]['ID']) {
                    html += "<a href=\"{:U('EditBookIndex')}?ID="
                            + useSet[i]['ID'] + "\" target='_blank'><button class='btn  btn-primary' >编辑</button></a> ";
                    html += "<span onclick='showcz($(this))' >更多</span><br/>";
                    html += "<div hidden >";
//                    html += "<a href=\"{:U('EditBookPicIndex')}?ID="
//                            + useSet[i]['ID'] + "\"><button class='btn  btn-primary' >书籍内图</button></a><br/> " ;
                    if (useSet[i]['IS_BLACK'] == 1) {
                        html += "<span class='btn'>已加入收书黑名单</span> <br/>";
                    } else {
                        html += "<button class='btn  btn-primary' onclick='AddBlackBook(" + useSet[i]['ID'] + ",$(this))'>加入收书黑名单</button> <br/>";

                    }
                    html += "<button class='btn  btn-primary' onclick='del(" + useSet[i]['ID'] + ",$(this))'>删除</button> <br/>";
                    if ("{$SGCODE}" != 0) {
                        html += "<button onclick='RuKu(" + useSet[i]['ID'] + ",$(this))'>导入书柜</button> ";
                    }
                    if ("{$banner_id}" != 0) {
                        html += "<button onclick='BookList(" + useSet[i]['ID'] + ",$(this))'>导入书单</button> ";
                    }
                    if ("{$SS}" != 0) {
                        html += "<button onclick='AddSBook(" + useSet[i]['ID'] + ",$(this))'>添加收书书籍</button> ";
                    }
                    if ("{$TZ}" != 0) {
                        html += "<button onclick='AddTzBook(" + useSet[i]['ID'] + ",$(this))'>属于套装书</button> ";
                    }
                    if ("{$BY}" != 0) {
                        html += "<button onclick='AddByBook(" + useSet[i]['ID'] + ",$(this))'>是否包邮</button> ";
                    }
                    html += "<div/>";
                } else {
                    html += "<a href=\"{:U('DRbook')}?id=" + useSet[i]['booklistid'] + "\"><button>导入</button></a> ";
                }
                html += "</td>";
                html += "</tr>";
                $("#context").append(html);
                for (var m = 0; m < showList.length; m++) {
                    console.log(showList[m]);
                    $("#list" + showList[m]).show();
                    $(".list" + showList[m]).show();
                }
            }

        };

    });

</script>
<script>

    //加入收书黑名单
    function AddBlackBook(ID, elem) {
        if (confirm("确认加入？")) {
            $.post("{:U('BlackBook/Add')}",
                    {ID: ID},
                    function (data) {
                        console.log(data);
                        if (parseInt(data) > 0) {
                            $elem.parent().parent().parent().remove();
                            alert('导入成功');
                        } else {
                            alert('导入失败');
                        }
                    });
        }
    }

    //导入套装书
    function AddTzBook(BOOK_ID, $elem) {
        if (confirm("确认导入？")) {
            $.post("{:U('Book/AddTzBook')}",
                    {BOOK_ID: BOOK_ID, TZ_BOOK_LIST_ID: "{$TZ}"},
                    function (data) {
                        console.log(data);
                        if (parseInt(data) > 0) {
                            $elem.parent().parent().parent().remove();
                            alert('导入成功');
                        } else {
                            alert('导入失败');
                        }
                    });
        }
    }

    //导入包邮书籍
    function AddByBook(BOOK_ID, $elem) {
        if (confirm("确认导入？")) {
            $.post("{:U('Postage/AddBYBook')}",
                    {BOOK_ID: BOOK_ID},
                    function (data) {
                        console.log(data);
                        if (parseInt(data) > 0) {
                            $elem.parent().parent().parent().remove();
                            alert('导入成功');
                        } else {
                            alert('导入失败');
                        }
                    });
        }
    }

    //    排序
    function sort(elem) {
        var sortNAME = elem.attr("name");
        var isDESC = elem.attr("data-type");
        if (isDESC) {
            if (isDESC == 'DESC') {
                isDESC = 'ASC'
            } else {
                isDESC = 'DESC'
            }
        } else {
            isDESC = 'DESC'
        }
        location.href = "{:U('Index')}?sortNAME=" + sortNAME + "&isDESC=" + isDESC;
        //location.href实现客户端页面的跳转
    }
    //    显示操作
    function showcz(elem) {
        if (elem.next().next().is(":hidden")) {
            elem.next().next().show();    //如果元素为隐藏,则将它显现
        } else {
            elem.next().next().hide();     //如果元素为显现,则将其隐藏
        }
    }

    function qx() {
        $("#allayModal_2").modal("hide");
        $("#allayModal_1").modal("show");
    }
    function qr() {
        var cs = $("#cs_data").html();
        var ID = $("#LL_BOOK_ID").val();
        $.post("{:U('Level/qrhandling')}",
                {cs: cs, ID: ID},
                function (data) {
                    console.log(data);
                    if (data == 1) {
                        alert('修改成功');
                        $("#allayModal_2").modal("hide");
                    } else {
                        alert(data);
                    }

                });
    }
    <!-- 成色选择器处理 -->
    function Level_handling() {
        var vals = [];
        $("input[name='jsd']:checkbox:checked").each(function (index, item) {
            vals.push($(this).val());
            $(this).attr("checked", false);
        });
//        alert(vals);
        $.post("{:U('Level/handling')}",
                {IDS: vals},
                function (data) {
                    console.log(data);
                    if (data) {
                        $("#allayModal_1").modal("hide");
                        $("#cs_data").html(data);
                        $("#allayModal_2").modal("show");
                    } else {

                    }

                });
    }
    <!--成色选择器显示-->
    function selectLevel(ID, elem) {
        $("#LL_BOOK_ID").val(ID);
        $("#allayModal_1").modal("show");
    }

    function addbook_fb(ID, name, XS_PRICE) {
        $("#XS_PRICE").val(XS_PRICE);
        $("#book_name_fb").val(name);
        $("#BOOK_ID").val(ID);
        $("#allayModal").modal("show");
    }
    <!--全选择框-->
    $("#all_checkbox").click(function () {
        if ($(this).is(':checked')) {
            $("input[name='checkbox']").prop("checked", "true");
        } else {
            $("input[name='checkbox']").removeAttr("checked", false);

        }
    });
    function checkboxID() {
        var vals = [];
        $("input[name='checkbox']:checkbox:checked").each(function (index, item) {
            vals.push($(this).val());
            $(this).hide();
        });
        if (vals.length <= 0) {
            alert('请选择书籍');
            return 0;
        }
        console.log(vals);
        $.post("{:U('Basket/AddAll')}",
                {IDS: vals},
                function (data) {
                    console.log(data);
                    if (parseInt(data)) {
                        alert('导入书篮子成功');
                        $("input[name='checkbox']:checkbox:checked").each(function (index, item) {
                            $(this).hide();
                        });
                    } else {
                        alert('导入书篮子失败');
                    }
                });
    }
    function updateSTOCK(ID, elem, top) {
        $.post("{:U('updateSTOCK')}",
                {ID: ID, top: top},
                function (data) {
                    if (parseInt(data) >= 0) {
                        if (top == 1) {
                            elem.next().html(data);
                        } else {
                            elem.prev().html(data);
                        }
                    } else {
                        alert('修改失败,库存不能小于0');
                        window.location.reload()
                    }
                });
    }
    function del(ID, $elem) {
        if (confirm("确认删除？")) {
            $.post("{:U('delete')}",
                    {ID: ID},
                    function (data) {
                        if (parseInt(data) == 1) {
                            $elem.parent().parent().parent().remove();
                            alert('删除成功');
                        } else {
                            alert('删除失败');
                        }
                    });
        }
    }
    function GetWZ(ID, $elem) {
        $.post("{:U('GetWZ')}",
                {ID: ID},
                function (data) {
                    alert(data);
                });

    }
    function RuKu(ID, $elem) {
        if (confirm("确认入库？")) {
            $.post("{:U('RuKu')}",
                    {ID: ID, SGCODE: "{$SGCODE}"},
                    function (data) {
                        if (parseInt(data) == 1) {
                            $elem.parent().parent().remove();
                            alert('入库成功');
                        } else {
                            alert('入库失败');
                        }
                    });
        }
    }
    //导入书单
    function BookList(ID, $elem) {
        if (confirm("确认导入？")) {
            $.post("{:U('BookList/AddBook')}",
                    {ID: ID, banner_id: "{$banner_id}"},
                    function (data) {
                        if (parseInt(data) == 1) {
                            $elem.parent().parent().parent().remove();
                            alert('导入成功');
                        } else {
                            alert('导入失败');
                        }
                    });
        }
    }

    //添加收书书籍
    function AddSBook(ID, $elem) {
        if (confirm("确认添加？")) {
            $.post("{:U('SBook/AddSBook')}",
                    {ID: ID},
                    function (data) {
                        if (data == 1) {
                            $elem.parent().parent().parent().remove();
                            alert('导入成功');
                        } else if (data == -1) {
                            alert('收书数据库已经存在改书籍');
                        } else {
                            alert('导入失败');
                        }
                    });
        }
    }

    //上-下架
    function updateShelves(ID, $elem) {
        var id = $elem.attr("data-id");
        var shelves = $elem.attr("data-shelves");

        var str = "";
        var newshelves = "";
        if (shelves == 0) {
            str = "确定上架该书籍吗？";
            newshelves = 1;
        } else {
            str = "确定下架该书籍吗？";
            newshelves = 0;
        }
        if (confirm(str)) {
            $.post("{:U('updateShelves')}",
                    {ID: ID, SXJ: newshelves},
                    function (data) {
                        if (parseInt(data) == 1) {
                            if (newshelves == 1) {
                                $elem.attr("data-shelves", 1);
                                $elem.prev().html('上架中');
                                $elem.prev().css('color', '#008200');
                            } else {
                                $elem.attr("data-shelves", 0);
                                $elem.prev().css('color', 'red');
                                $elem.prev().html('已下架');
                            }
                            alert('修改成功');
                        } else {
                            alert('修改失败');
                        }
                    });
        }


    }

</script>

</body>

</html>
